import React from "react";
import { HashRouter as Router , Switch , Route, Redirect } from "react-router-dom"
import MainLayout from "./layout/main/index.jsx";
import Login from "./views/login/Index.jsx"
import { connect } from "react-redux";

const App = ({loginState}) => {
    return (
        <Router>
            <Switch>
                <Route path="/login" component = {Login} />
                {/* <Route path='/' component={MainLayout} ></Route> */}
                <Route path='/' render={() => {
                    return loginState ? <MainLayout/> : <Redirect to='/login' />
                }} ></Route>
            </Switch>
        </Router>
    )
}

export default connect(
    state => ({
        loginState:state.getIn(['user' , 'loginState'])
    })
)(App)